﻿using System.Collections;
using System.Collections.Generic;
using System.Net;
using com.tdb.foundation;
using com.tdb.posion.protocol.protobuf;
using DG.Tweening;
using Posion.Model;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

public class CreateRoomView : BaseView
{
    [SerializeField]
    private InputField _roomName;
    [SerializeField]
    private Button _btn;
    [SerializeField]
    private GameObject _dialog;

    private CreateRoomContext _context;

    public override void OnEnter(BaseContext context, UnityAction callback)
    {
        _dialog.transform.localScale = Vector3.zero;
        gameObject.SetActive(true);
        _dialog.transform.DOScale(1, .25f);
        _btn.onClick.RemoveAllListeners();
        _btn.onClick.AddListener(ConfirmBtnClick);
        _context = context as CreateRoomContext;
    }


    private void ConfirmBtnClick()
    {
        if (_roomName.text.IsNOTNullOrEmpty())
        {
            _context.CreateRoom();
            UIManager.Instance.OpenView(new RoomContext(_roomName.text),OpenType.Single);
        }
        else
        {
            GlobalUIManager.Instance.ModalDialog.ShowTips(TxtConst.Instance.CreateRoomNotNull);
        }
    }
    
}

public class CreateRoomContext : BaseContext
{
    public CreateRoomContext() : base(UIType.CreateRoom)
    {
        
    }

    public void CreateRoom()
    {
        
    }
}